import { request } from "../../utils/request.js";
import regeneratorRuntime from "../../utils/runtime.js";
var bsurl = require('../../utils/bsurl.js');
let flashEvent = require('../../utils/FlashEvent.js')
let  app =getApp();
Page({
    data: {
        userid:'',
        createlist:[]
    },
    playlist:[],
    async getplaylist(){
        const {userid}=this.data
        const result=await request({url:bsurl+'user/playlist?uid='+userid});           
        const createlist=result.playlist.map(v=>{
            return {
                name:v.name,
                id:v.id,
                coverImgUrl:v.coverImgUrl,
                trackCount:v.trackCount,
                playCount:v.playCount
            }
        });
        this.setData({
            createlist
        })
    },
    onLoad: function(options) {
        const userinfo=wx.getStorageSync("userinfo");
        if(!userinfo){
          wx.reLaunch({
              url: '/pages/login/index',
          });
        }
        else{
            const userid=userinfo.userId;
            this.setData({
                userid
            })
            this.getplaylist(); 
        }
    },
    onShow: function() {
        const userinfo=wx.getStorageSync("userinfo");
    }
});
  